package simple.utils.tracking.storage;

import java.util.Arrays;

/**
 * Cassandra db compares by equals, so primitive arrays must be wrapped by some class
 * Created by martin on 14.5.14.
 */
public class CassandraByteArrayKey {
    private final byte[] key;

    public CassandraByteArrayKey(byte[] key) {
        this.key = key;
    }

    public byte[] getKey() {
        return key;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        CassandraByteArrayKey that = (CassandraByteArrayKey) o;
        return Arrays.equals(key, that.key);
    }

    @Override
    public int hashCode() {
        return key != null ? Arrays.hashCode(key) : 0;
    }
}
